﻿namespace OverStore.Exceptions
{
    using System;

    /// <summary>
    /// The exception that is thrown when trying to store instance changed outside of persistence session.
    /// </summary>
    public sealed class VersionConflictException : Exception
    {
/// <summary>
        /// Initializes new instance of VersionConflictException.
        /// </summary>
        /// <param name="instance">The instance causes and version conflict.</param>
        public VersionConflictException(object instance)
            : base("Version conflict is occured")
        {
            if (instance == null)
                throw new ArgumentNullException("instance");
            Instance = instance;
        }

        /// <summary>
        /// Get instance which storaging causes version conflict.
        /// </summary>
        public object Instance { get; private set; }
    }
}